package thread;

public class Thread_isAlive {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() ->{
            //该线程执行时间大约是1s
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
            }
        });
        //判断当前的线程是否处于活动状态
        System.out.println("start之前: "+t.isAlive());
        t.start();
        System.out.println("start之后："+t.isAlive());
        //2s后该线程t结束
        Thread.sleep(2000);
        System.out.println("t结束后:"+t.isAlive());
    }
}
